<?php
include('connect.php');
header('Content-Type:application/json'); 
// $userlat = $_GET['userlat'];
// $userlog = $_GET['userlog'];
$useropenid = $_GET['useropenid'];
// 创建连接


//向数据库中插入数据
$sql = "INSERT INTO list (useropenid,userlat,userlog,msgpowernum) VALUES ('".$useropenid."','1','1',0)";
if ($db->query($sql) === TRUE) {
	$json['powernum']=0;
	$json['msg']="success";
    echo json_encode($json);
} else {
   $json['msg']="Error creating database: " . $db->error;
   $sql="select msgpowernum from list where useropenid='".$useropenid."'";
   $s = mysqli_fetch_all(mysqli_query($db,$sql),MYSQLI_ASSOC);
   $json['powernum']=$s[0]['msgpowernum'];
   echo json_encode($json);
}

$db->close();
?>
